package com.aoxon.cargo.activity.fragment;

import java.util.Calendar;

import psnl.littlemouse.vpwid.TabInfo;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.aoxon.cargo.R;
import com.aoxon.cargo.component.GoodsWaterFall;
import com.aoxon.cargo.activity.fragment.PurFragment;

@SuppressLint("ValidFragment")
public class NewPurFragment extends PurFragment{
	
	Activity activity;
	public NewPurFragment(TabInfo tb, String myService, boolean isIndex) {
		super(tb, myService, isIndex);
		// TODO Auto-generated constructor stub
		this.activity = getActivity();
	}
	
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		GoodsWaterFall waterFall = (GoodsWaterFall) inflater.inflate(
				R.layout.water_fall, null );
		
		waterFall.init(2);
		waterFall.addViewInColumn(0, getTimeBox(inflater), 1);
		waterFall.load();
		return waterFall;
//		View view = inflater.inflate(
//				R.layout.water_fall, null );
//		View child = view.findViewById(R.id.ll_root);
//		Log.v("child", ""+(child==null));
//		return view;
	}
	
	private View getTimeBox(LayoutInflater inflater) {
		View timeBox = inflater.inflate(R.layout.time_box, null);
		TextView tv_day = (TextView) timeBox.findViewById(R.id.tv_day);
		TextView tv_week = (TextView) timeBox.findViewById(R.id.tv_week);
		TextView tv_date = (TextView) timeBox.findViewById(R.id.tv_date);

		final Calendar c = Calendar.getInstance();
		tv_day.setText(String.valueOf(c.get(Calendar.DAY_OF_MONTH)));

		final int month = c.get(Calendar.MONTH) + 1;
		StringBuilder sb = new StringBuilder().append(c.get(Calendar.YEAR))
				.append("-");
		if (month >= 10)
			sb.append(month);
		else
			sb.append("0").append(month);
		tv_date.setText(sb.toString());

		final int week = c.get(Calendar.DAY_OF_WEEK) - 1;
		switch (week) {
		case 0:
			tv_week.setText("星期日");
			break;
		case 1:
			tv_week.setText("星期一");
			break;
		case 2:
			tv_week.setText("星期二");
			break;
		case 3:
			tv_week.setText("星期三");
			break;
		case 4:
			tv_week.setText("星期四");
			break;
		case 5:
			tv_week.setText("星期五");
			break;
		case 6:
			tv_week.setText("星期六");
			break;
		default:
			break;
		}
		return timeBox;
	}
	
//	@Override
//	public void onPause() {
//		// TODO Auto-generated method stub
//	}
//
//	@Override
//	public void onResume() {
//		// TODO Auto-generated method stub
//		super.onResume();
//	}
	
}
